{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from math import log"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>humility</th>\n",
       "      <th>outlook</th>\n",
       "      <th>play</th>\n",
       "      <th>temp</th>\n",
       "      <th>windy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>high</td>\n",
       "      <td>sunny</td>\n",
       "      <td>no</td>\n",
       "      <td>hot</td>\n",
       "      <td>false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>high</td>\n",
       "      <td>sunny</td>\n",
       "      <td>no</td>\n",
       "      <td>hot</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>high</td>\n",
       "      <td>overcast</td>\n",
       "      <td>yes</td>\n",
       "      <td>hot</td>\n",
       "      <td>false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>high</td>\n",
       "      <td>rainy</td>\n",
       "      <td>yes</td>\n",
       "      <td>mild</td>\n",
       "      <td>false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>normal</td>\n",
       "      <td>rainy</td>\n",
       "      <td>yes</td>\n",
       "      <td>cool</td>\n",
       "      <td>false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>normal</td>\n",
       "      <td>rainy</td>\n",
       "      <td>no</td>\n",
       "      <td>cool</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>normal</td>\n",
       "      <td>overcast</td>\n",
       "      <td>yes</td>\n",
       "      <td>cool</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>high</td>\n",
       "      <td>sunny</td>\n",
       "      <td>no</td>\n",
       "      <td>mild</td>\n",
       "      <td>false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>normal</td>\n",
       "      <td>sunny</td>\n",
       "      <td>yes</td>\n",
       "      <td>cool</td>\n",
       "      <td>false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>normal</td>\n",
       "      <td>rainy</td>\n",
       "      <td>yes</td>\n",
       "      <td>mild</td>\n",
       "      <td>false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>normal</td>\n",
       "      <td>sunny</td>\n",
       "      <td>yes</td>\n",
       "      <td>mild</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>high</td>\n",
       "      <td>overcast</td>\n",
       "      <td>yes</td>\n",
       "      <td>mild</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>normal</td>\n",
       "      <td>overcast</td>\n",
       "      <td>yes</td>\n",
       "      <td>hot</td>\n",
       "      <td>false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>high</td>\n",
       "      <td>rainy</td>\n",
       "      <td>no</td>\n",
       "      <td>mild</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   humility   outlook play  temp  windy\n",
       "0      high     sunny   no   hot  false\n",
       "1      high     sunny   no   hot   true\n",
       "2      high  overcast  yes   hot  false\n",
       "3      high     rainy  yes  mild  false\n",
       "4    normal     rainy  yes  cool  false\n",
       "5    normal     rainy   no  cool   true\n",
       "6    normal  overcast  yes  cool   true\n",
       "7      high     sunny   no  mild  false\n",
       "8    normal     sunny  yes  cool  false\n",
       "9    normal     rainy  yes  mild  false\n",
       "10   normal     sunny  yes  mild   true\n",
       "11     high  overcast  yes  mild   true\n",
       "12   normal  overcast  yes   hot  false\n",
       "13     high     rainy   no  mild   true"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('./example_data.csv', dtype={'windy': 'str'})\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def entropy(ele):\n",
    "    probs = [ele.count(i)/len(ele) for i in set(ele)]\n",
    "    entropy = -sum([prob*log(prob, 2) for prob in probs])\n",
    "    return entropy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9402859586706309"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "entropy(df['play'].tolist())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def split_dataframe(data, col):\n",
    "    unique_values = data[col].unique()\n",
    "    result_dict = {elem : pd.DataFrame for elem in unique_values}\n",
    "    for key in result_dict.keys():\n",
    "        result_dict[key] = data[:][data[col] == key]\n",
    "    return result_dict\n",
    "\n",
    "split_example = split_dataframe(df, 'temp')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hot    humility   outlook play temp  windy\n",
      "0      high     sunny   no  hot  false\n",
      "1      high     sunny   no  hot   true\n",
      "2      high  overcast  yes  hot  false\n",
      "12   normal  overcast  yes  hot  false\n",
      "mild    humility   outlook play  temp  windy\n",
      "3      high     rainy  yes  mild  false\n",
      "7      high     sunny   no  mild  false\n",
      "9    normal     rainy  yes  mild  false\n",
      "10   normal     sunny  yes  mild   true\n",
      "11     high  overcast  yes  mild   true\n",
      "13     high     rainy   no  mild   true\n",
      "cool   humility   outlook play  temp  windy\n",
      "4   normal     rainy  yes  cool  false\n",
      "5   normal     rainy   no  cool   true\n",
      "6   normal  overcast  yes  cool   true\n",
      "8   normal     sunny  yes  cool  false\n"
     ]
    }
   ],
   "source": [
    "for item, value in split_example.items():\n",
    "    print(item, value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.2467498197744391, 'outlook', {'sunny':    outlook  temp humility  windy play\n",
       "  0    sunny   hot     high  False   no\n",
       "  1    sunny   hot     high   True   no\n",
       "  7    sunny  mild     high  False   no\n",
       "  8    sunny  cool   normal  False  yes\n",
       "  10   sunny  mild   normal   True  yes,\n",
       "  'overcast':      outlook  temp humility  windy play\n",
       "  2   overcast   hot     high  False  yes\n",
       "  6   overcast  cool   normal   True  yes\n",
       "  11  overcast  mild     high   True  yes\n",
       "  12  overcast   hot   normal  False  yes,\n",
       "  'rainy':    outlook  temp humility  windy play\n",
       "  3    rainy  mild     high  False  yes\n",
       "  4    rainy  cool   normal  False  yes\n",
       "  5    rainy  cool   normal   True   no\n",
       "  9    rainy  mild   normal  False  yes\n",
       "  13   rainy  mild     high   True   no})"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def choose_best_col(df, label):\n",
    "    entropy_D = entropy(df[label].tolist())\n",
    "    cols = [col for col in df.columns if col not in [label]]\n",
    "    max_value, best_col = -999, None\n",
    "    max_splited = None\n",
    "    for col in cols:\n",
    "        splited_set = split_dataframe(df, col)\n",
    "        entropy_DA = 0\n",
    "        for subset_col, subset in splited_set.items():\n",
    "            entropy_Di = entropy(subset[label].tolist())\n",
    "            entropy_DA += len(subset)/len(df) * entropy_Di\n",
    "        info_gain = entropy_D - entropy_DA\n",
    "        \n",
    "        if info_gain > max_value:\n",
    "            max_value, best_col = info_gain, col\n",
    "            max_splited = splited_set\n",
    "    return max_value, best_col, max_splited\n",
    "    \n",
    "choose_best_col(df, 'play')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "class ID3Tree:\n",
    "    class Node:\n",
    "        def __init__(self, name):\n",
    "            self.name = name\n",
    "            self.connections = {}\n",
    "\n",
    "        def connect(self, label, node):\n",
    "            self.connections[label] = node\n",
    "            \n",
    "    def __init__(self, data, label):\n",
    "        self.columns = data.columns\n",
    "        self.data = data\n",
    "        self.label = label\n",
    "        self.root = self.Node(\"Root\")\n",
    "        \n",
    "    def print_tree(self, node, tabs):\n",
    "        print(tabs + node.name)\n",
    "        for connection, child_node in node.connections.items():\n",
    "            print(tabs + \"\\t\" + \"(\" + connection + \")\")\n",
    "            self.print_tree(child_node, tabs + \"\\t\\t\")\n",
    "\n",
    "    def construct_tree(self):\n",
    "        self.construct(self.root, \"\", self.data, self.columns)\n",
    "        \n",
    "    def construct(self, parent_node, parent_connection_label, input_data, columns):\n",
    "        max_value, best_col, max_splited = choose_best_col(input_data[columns], self.label)\n",
    "        \n",
    "        if not best_col:\n",
    "            node = self.Node(input_data[self.label].iloc[0])\n",
    "            parent_node.connect(parent_connection_label, node)\n",
    "            return\n",
    "\n",
    "        node = self.Node(best_col)\n",
    "        parent_node.connect(parent_connection_label, node)\n",
    "        \n",
    "        new_columns = [col for col in columns if col != best_col]\n",
    "        \n",
    "        for splited_value, splited_data in max_splited.items():\n",
    "            self.construct(node, splited_value, splited_data, new_columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "tree1 = ID3Tree(df, 'play')\n",
    "tree1.construct_tree()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Root\n",
      "\t()\n",
      "\t\toutlook\n",
      "\t\t\t(sunny)\n",
      "\t\t\t\thumility\n",
      "\t\t\t\t\t(high)\n",
      "\t\t\t\t\t\ttemp\n",
      "\t\t\t\t\t\t\t(hot)\n",
      "\t\t\t\t\t\t\t\twindy\n",
      "\t\t\t\t\t\t\t\t\t(FALSE)\n",
      "\t\t\t\t\t\t\t\t\t\tno\n",
      "\t\t\t\t\t\t\t\t\t(TRUE)\n",
      "\t\t\t\t\t\t\t\t\t\tno\n",
      "\t\t\t\t\t\t\t(mild)\n",
      "\t\t\t\t\t\t\t\twindy\n",
      "\t\t\t\t\t\t\t\t\t(FALSE)\n",
      "\t\t\t\t\t\t\t\t\t\tno\n",
      "\t\t\t\t\t(normal)\n",
      "\t\t\t\t\t\ttemp\n",
      "\t\t\t\t\t\t\t(cool)\n",
      "\t\t\t\t\t\t\t\twindy\n",
      "\t\t\t\t\t\t\t\t\t(FALSE)\n",
      "\t\t\t\t\t\t\t\t\t\tyes\n",
      "\t\t\t\t\t\t\t(mild)\n",
      "\t\t\t\t\t\t\t\twindy\n",
      "\t\t\t\t\t\t\t\t\t(TRUE)\n",
      "\t\t\t\t\t\t\t\t\t\tyes\n",
      "\t\t\t(overcast)\n",
      "\t\t\t\ttemp\n",
      "\t\t\t\t\t(hot)\n",
      "\t\t\t\t\t\thumility\n",
      "\t\t\t\t\t\t\t(high)\n",
      "\t\t\t\t\t\t\t\twindy\n",
      "\t\t\t\t\t\t\t\t\t(FALSE)\n",
      "\t\t\t\t\t\t\t\t\t\tyes\n",
      "\t\t\t\t\t\t\t(normal)\n",
      "\t\t\t\t\t\t\t\twindy\n",
      "\t\t\t\t\t\t\t\t\t(FALSE)\n",
      "\t\t\t\t\t\t\t\t\t\tyes\n",
      "\t\t\t\t\t(cool)\n",
      "\t\t\t\t\t\thumility\n",
      "\t\t\t\t\t\t\t(normal)\n",
      "\t\t\t\t\t\t\t\twindy\n",
      "\t\t\t\t\t\t\t\t\t(TRUE)\n",
      "\t\t\t\t\t\t\t\t\t\tyes\n",
      "\t\t\t\t\t(mild)\n",
      "\t\t\t\t\t\thumility\n",
      "\t\t\t\t\t\t\t(high)\n",
      "\t\t\t\t\t\t\t\twindy\n",
      "\t\t\t\t\t\t\t\t\t(TRUE)\n",
      "\t\t\t\t\t\t\t\t\t\tyes\n",
      "\t\t\t(rainy)\n",
      "\t\t\t\twindy\n",
      "\t\t\t\t\t(FALSE)\n",
      "\t\t\t\t\t\ttemp\n",
      "\t\t\t\t\t\t\t(mild)\n",
      "\t\t\t\t\t\t\t\thumility\n",
      "\t\t\t\t\t\t\t\t\t(high)\n",
      "\t\t\t\t\t\t\t\t\t\tyes\n",
      "\t\t\t\t\t\t\t\t\t(normal)\n",
      "\t\t\t\t\t\t\t\t\t\tyes\n",
      "\t\t\t\t\t\t\t(cool)\n",
      "\t\t\t\t\t\t\t\thumility\n",
      "\t\t\t\t\t\t\t\t\t(normal)\n",
      "\t\t\t\t\t\t\t\t\t\tyes\n",
      "\t\t\t\t\t(TRUE)\n",
      "\t\t\t\t\t\ttemp\n",
      "\t\t\t\t\t\t\t(cool)\n",
      "\t\t\t\t\t\t\t\thumility\n",
      "\t\t\t\t\t\t\t\t\t(normal)\n",
      "\t\t\t\t\t\t\t\t\t\tno\n",
      "\t\t\t\t\t\t\t(mild)\n",
      "\t\t\t\t\t\t\t\thumility\n",
      "\t\t\t\t\t\t\t\t\t(high)\n",
      "\t\t\t\t\t\t\t\t\t\tno\n"
     ]
    }
   ],
   "source": [
    "tree1.print_tree(tree1.root, \"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn import tree\n",
    "X = [[0, 0], [1, 1]]\n",
    "Y = [0, 1]\n",
    "clf = tree.DecisionTreeClassifier()\n",
    "clf = clf.fit(X, Y)\n",
    "clf.predict([[2, 2]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.datasets import load_iris\n",
    "from sklearn import tree\n",
    "\n",
    "iris = load_iris()\n",
    "clf = tree.DecisionTreeClassifier(criterion='entropy', splitter='best')\n",
    "clf = clf.fit(iris.data, iris.target)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'iris.pdf'"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import graphviz\n",
    "dot_data = tree.export_graphviz(clf, out_file=None)\n",
    "graph = graphviz.Source(dot_data)\n",
    "graph.render('iris')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\r\n",
       " -->\r\n",
       "<!-- Title: Tree Pages: 1 -->\r\n",
       "<svg width=\"896pt\" height=\"671pt\"\r\n",
       " viewBox=\"0.00 0.00 896.00 671.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 667)\">\r\n",
       "<title>Tree</title>\r\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-667 892,-667 892,4 -4,4\"/>\r\n",
       "<!-- 0 -->\r\n",
       "<g id=\"node1\" class=\"node\"><title>0</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M539,-663C539,-663 398,-663 398,-663 392,-663 386,-657 386,-651 386,-651 386,-592 386,-592 386,-586 392,-580 398,-580 398,-580 539,-580 539,-580 545,-580 551,-586 551,-592 551,-592 551,-651 551,-651 551,-657 545,-663 539,-663\"/>\r\n",
       "<text text-anchor=\"start\" x=\"394\" y=\"-647.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) ≤ 2.45</text>\r\n",
       "<text text-anchor=\"start\" x=\"418.5\" y=\"-632.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.585</text>\r\n",
       "<text text-anchor=\"start\" x=\"421\" y=\"-617.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 150</text>\r\n",
       "<text text-anchor=\"start\" x=\"408\" y=\"-602.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [50, 50, 50]</text>\r\n",
       "<text text-anchor=\"start\" x=\"422.5\" y=\"-587.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = setosa</text>\r\n",
       "</g>\r\n",
       "<!-- 1 -->\r\n",
       "<g id=\"node2\" class=\"node\"><title>1</title>\r\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M438,-536.5C438,-536.5 341,-536.5 341,-536.5 335,-536.5 329,-530.5 329,-524.5 329,-524.5 329,-480.5 329,-480.5 329,-474.5 335,-468.5 341,-468.5 341,-468.5 438,-468.5 438,-468.5 444,-468.5 450,-474.5 450,-480.5 450,-480.5 450,-524.5 450,-524.5 450,-530.5 444,-536.5 438,-536.5\"/>\r\n",
       "<text text-anchor=\"start\" x=\"347.5\" y=\"-521.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"346\" y=\"-506.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 50</text>\r\n",
       "<text text-anchor=\"start\" x=\"337\" y=\"-491.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [50, 0, 0]</text>\r\n",
       "<text text-anchor=\"start\" x=\"343.5\" y=\"-476.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = setosa</text>\r\n",
       "</g>\r\n",
       "<!-- 0&#45;&gt;1 -->\r\n",
       "<g id=\"edge1\" class=\"edge\"><title>0&#45;&gt;1</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M441.091,-579.907C433.492,-568.652 425.231,-556.418 417.593,-545.106\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"420.391,-542.996 411.895,-536.667 414.59,-546.913 420.391,-542.996\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"407.136\" y=\"-557.51\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\r\n",
       "</g>\r\n",
       "<!-- 2 -->\r\n",
       "<g id=\"node3\" class=\"node\"><title>2</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M615,-544C615,-544 480,-544 480,-544 474,-544 468,-538 468,-532 468,-532 468,-473 468,-473 468,-467 474,-461 480,-461 480,-461 615,-461 615,-461 621,-461 627,-467 627,-473 627,-473 627,-532 627,-532 627,-538 621,-544 615,-544\"/>\r\n",
       "<text text-anchor=\"start\" x=\"476\" y=\"-528.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) ≤ 1.75</text>\r\n",
       "<text text-anchor=\"start\" x=\"505.5\" y=\"-513.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"500\" y=\"-498.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 100</text>\r\n",
       "<text text-anchor=\"start\" x=\"491\" y=\"-483.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 50, 50]</text>\r\n",
       "<text text-anchor=\"start\" x=\"492\" y=\"-468.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\r\n",
       "</g>\r\n",
       "<!-- 0&#45;&gt;2 -->\r\n",
       "<g id=\"edge2\" class=\"edge\"><title>0&#45;&gt;2</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M495.909,-579.907C501.914,-571.014 508.331,-561.509 514.529,-552.331\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"517.444,-554.267 520.14,-544.021 511.643,-550.35 517.444,-554.267\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"524.898\" y=\"-564.864\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\r\n",
       "</g>\r\n",
       "<!-- 3 -->\r\n",
       "<g id=\"node4\" class=\"node\"><title>3</title>\r\n",
       "<path fill=\"#39e581\" fill-opacity=\"0.898039\" stroke=\"black\" d=\"M502,-425C502,-425 361,-425 361,-425 355,-425 349,-419 349,-413 349,-413 349,-354 349,-354 349,-348 355,-342 361,-342 361,-342 502,-342 502,-342 508,-342 514,-348 514,-354 514,-354 514,-413 514,-413 514,-419 508,-425 502,-425\"/>\r\n",
       "<text text-anchor=\"start\" x=\"357\" y=\"-409.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) ≤ 4.95</text>\r\n",
       "<text text-anchor=\"start\" x=\"381.5\" y=\"-394.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.445</text>\r\n",
       "<text text-anchor=\"start\" x=\"388\" y=\"-379.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 54</text>\r\n",
       "<text text-anchor=\"start\" x=\"379\" y=\"-364.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 49, 5]</text>\r\n",
       "<text text-anchor=\"start\" x=\"376\" y=\"-349.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\r\n",
       "</g>\r\n",
       "<!-- 2&#45;&gt;3 -->\r\n",
       "<g id=\"edge3\" class=\"edge\"><title>2&#45;&gt;3</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M507.254,-460.907C498.077,-451.651 488.243,-441.732 478.801,-432.209\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"481.201,-429.658 471.674,-425.021 476.23,-434.586 481.201,-429.658\"/>\r\n",
       "</g>\r\n",
       "<!-- 12 -->\r\n",
       "<g id=\"node13\" class=\"node\"><title>12</title>\r\n",
       "<path fill=\"#8139e5\" fill-opacity=\"0.976471\" stroke=\"black\" d=\"M735,-425C735,-425 594,-425 594,-425 588,-425 582,-419 582,-413 582,-413 582,-354 582,-354 582,-348 588,-342 594,-342 594,-342 735,-342 735,-342 741,-342 747,-348 747,-354 747,-354 747,-413 747,-413 747,-419 741,-425 735,-425\"/>\r\n",
       "<text text-anchor=\"start\" x=\"590\" y=\"-409.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) ≤ 4.85</text>\r\n",
       "<text text-anchor=\"start\" x=\"614.5\" y=\"-394.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.151</text>\r\n",
       "<text text-anchor=\"start\" x=\"621\" y=\"-379.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 46</text>\r\n",
       "<text text-anchor=\"start\" x=\"612\" y=\"-364.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 45]</text>\r\n",
       "<text text-anchor=\"start\" x=\"614.5\" y=\"-349.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\r\n",
       "</g>\r\n",
       "<!-- 2&#45;&gt;12 -->\r\n",
       "<g id=\"edge12\" class=\"edge\"><title>2&#45;&gt;12</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M588.093,-460.907C597.349,-451.651 607.268,-441.732 616.791,-432.209\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"619.383,-434.567 623.979,-425.021 614.433,-429.617 619.383,-434.567\"/>\r\n",
       "</g>\r\n",
       "<!-- 4 -->\r\n",
       "<g id=\"node5\" class=\"node\"><title>4</title>\r\n",
       "<path fill=\"#39e581\" fill-opacity=\"0.980392\" stroke=\"black\" d=\"M271,-306C271,-306 136,-306 136,-306 130,-306 124,-300 124,-294 124,-294 124,-235 124,-235 124,-229 130,-223 136,-223 136,-223 271,-223 271,-223 277,-223 283,-229 283,-235 283,-235 283,-294 283,-294 283,-300 277,-306 271,-306\"/>\r\n",
       "<text text-anchor=\"start\" x=\"132\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) ≤ 1.65</text>\r\n",
       "<text text-anchor=\"start\" x=\"153.5\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.146</text>\r\n",
       "<text text-anchor=\"start\" x=\"160\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 48</text>\r\n",
       "<text text-anchor=\"start\" x=\"151\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 47, 1]</text>\r\n",
       "<text text-anchor=\"start\" x=\"148\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\r\n",
       "</g>\r\n",
       "<!-- 3&#45;&gt;4 -->\r\n",
       "<g id=\"edge4\" class=\"edge\"><title>3&#45;&gt;4</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M352.397,-341.907C332.766,-331.834 311.608,-320.977 291.578,-310.698\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"292.959,-307.472 282.464,-306.021 289.763,-313.7 292.959,-307.472\"/>\r\n",
       "</g>\r\n",
       "<!-- 7 -->\r\n",
       "<g id=\"node8\" class=\"node\"><title>7</title>\r\n",
       "<path fill=\"#8139e5\" fill-opacity=\"0.498039\" stroke=\"black\" d=\"M499,-306C499,-306 364,-306 364,-306 358,-306 352,-300 352,-294 352,-294 352,-235 352,-235 352,-229 358,-223 364,-223 364,-223 499,-223 499,-223 505,-223 511,-229 511,-235 511,-235 511,-294 511,-294 511,-300 505,-306 499,-306\"/>\r\n",
       "<text text-anchor=\"start\" x=\"360\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) ≤ 1.55</text>\r\n",
       "<text text-anchor=\"start\" x=\"381.5\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.918</text>\r\n",
       "<text text-anchor=\"start\" x=\"392\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 6</text>\r\n",
       "<text text-anchor=\"start\" x=\"383\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 4]</text>\r\n",
       "<text text-anchor=\"start\" x=\"381.5\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\r\n",
       "</g>\r\n",
       "<!-- 3&#45;&gt;7 -->\r\n",
       "<g id=\"edge7\" class=\"edge\"><title>3&#45;&gt;7</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M431.5,-341.907C431.5,-333.649 431.5,-324.864 431.5,-316.302\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"435,-316.021 431.5,-306.021 428,-316.021 435,-316.021\"/>\r\n",
       "</g>\r\n",
       "<!-- 5 -->\r\n",
       "<g id=\"node6\" class=\"node\"><title>5</title>\r\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M115,-179.5C115,-179.5 12,-179.5 12,-179.5 6,-179.5 -7.10543e-015,-173.5 -7.10543e-015,-167.5 -7.10543e-015,-167.5 -7.10543e-015,-123.5 -7.10543e-015,-123.5 -7.10543e-015,-117.5 6,-111.5 12,-111.5 12,-111.5 115,-111.5 115,-111.5 121,-111.5 127,-117.5 127,-123.5 127,-123.5 127,-167.5 127,-167.5 127,-173.5 121,-179.5 115,-179.5\"/>\r\n",
       "<text text-anchor=\"start\" x=\"21.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"20\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 47</text>\r\n",
       "<text text-anchor=\"start\" x=\"11\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 47, 0]</text>\r\n",
       "<text text-anchor=\"start\" x=\"8\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\r\n",
       "</g>\r\n",
       "<!-- 4&#45;&gt;5 -->\r\n",
       "<g id=\"edge5\" class=\"edge\"><title>4&#45;&gt;5</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M154.928,-222.907C140.668,-210.99 125.095,-197.976 110.908,-186.12\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"113.105,-183.394 103.187,-179.667 108.616,-188.765 113.105,-183.394\"/>\r\n",
       "</g>\r\n",
       "<!-- 6 -->\r\n",
       "<g id=\"node7\" class=\"node\"><title>6</title>\r\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M249.5,-179.5C249.5,-179.5 157.5,-179.5 157.5,-179.5 151.5,-179.5 145.5,-173.5 145.5,-167.5 145.5,-167.5 145.5,-123.5 145.5,-123.5 145.5,-117.5 151.5,-111.5 157.5,-111.5 157.5,-111.5 249.5,-111.5 249.5,-111.5 255.5,-111.5 261.5,-117.5 261.5,-123.5 261.5,-123.5 261.5,-167.5 261.5,-167.5 261.5,-173.5 255.5,-179.5 249.5,-179.5\"/>\r\n",
       "<text text-anchor=\"start\" x=\"161.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"164\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\r\n",
       "<text text-anchor=\"start\" x=\"155\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 1]</text>\r\n",
       "<text text-anchor=\"start\" x=\"153.5\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\r\n",
       "</g>\r\n",
       "<!-- 4&#45;&gt;6 -->\r\n",
       "<g id=\"edge6\" class=\"edge\"><title>4&#45;&gt;6</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M203.5,-222.907C203.5,-212.204 203.5,-200.615 203.5,-189.776\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"207,-189.667 203.5,-179.667 200,-189.667 207,-189.667\"/>\r\n",
       "</g>\r\n",
       "<!-- 8 -->\r\n",
       "<g id=\"node9\" class=\"node\"><title>8</title>\r\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M383.5,-179.5C383.5,-179.5 291.5,-179.5 291.5,-179.5 285.5,-179.5 279.5,-173.5 279.5,-167.5 279.5,-167.5 279.5,-123.5 279.5,-123.5 279.5,-117.5 285.5,-111.5 291.5,-111.5 291.5,-111.5 383.5,-111.5 383.5,-111.5 389.5,-111.5 395.5,-117.5 395.5,-123.5 395.5,-123.5 395.5,-167.5 395.5,-167.5 395.5,-173.5 389.5,-179.5 383.5,-179.5\"/>\r\n",
       "<text text-anchor=\"start\" x=\"295.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"298\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\r\n",
       "<text text-anchor=\"start\" x=\"289\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 3]</text>\r\n",
       "<text text-anchor=\"start\" x=\"287.5\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\r\n",
       "</g>\r\n",
       "<!-- 7&#45;&gt;8 -->\r\n",
       "<g id=\"edge8\" class=\"edge\"><title>7&#45;&gt;8</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M398.887,-222.907C389.756,-211.542 379.823,-199.178 370.66,-187.774\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"373.139,-185.271 364.147,-179.667 367.682,-189.655 373.139,-185.271\"/>\r\n",
       "</g>\r\n",
       "<!-- 9 -->\r\n",
       "<g id=\"node10\" class=\"node\"><title>9</title>\r\n",
       "<path fill=\"#39e581\" fill-opacity=\"0.498039\" stroke=\"black\" d=\"M571,-187C571,-187 426,-187 426,-187 420,-187 414,-181 414,-175 414,-175 414,-116 414,-116 414,-110 420,-104 426,-104 426,-104 571,-104 571,-104 577,-104 583,-110 583,-116 583,-116 583,-175 583,-175 583,-181 577,-187 571,-187\"/>\r\n",
       "<text text-anchor=\"start\" x=\"422\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">sepal length (cm) ≤ 6.95</text>\r\n",
       "<text text-anchor=\"start\" x=\"448.5\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.918</text>\r\n",
       "<text text-anchor=\"start\" x=\"459\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\r\n",
       "<text text-anchor=\"start\" x=\"450\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 1]</text>\r\n",
       "<text text-anchor=\"start\" x=\"443\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\r\n",
       "</g>\r\n",
       "<!-- 7&#45;&gt;9 -->\r\n",
       "<g id=\"edge9\" class=\"edge\"><title>7&#45;&gt;9</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M454.745,-222.907C459.734,-214.195 465.059,-204.897 470.215,-195.893\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"473.364,-197.438 475.296,-187.021 467.289,-193.959 473.364,-197.438\"/>\r\n",
       "</g>\r\n",
       "<!-- 10 -->\r\n",
       "<g id=\"node11\" class=\"node\"><title>10</title>\r\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M480,-68C480,-68 377,-68 377,-68 371,-68 365,-62 365,-56 365,-56 365,-12 365,-12 365,-6 371,-0 377,-0 377,-0 480,-0 480,-0 486,-0 492,-6 492,-12 492,-12 492,-56 492,-56 492,-62 486,-68 480,-68\"/>\r\n",
       "<text text-anchor=\"start\" x=\"386.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"389\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\r\n",
       "<text text-anchor=\"start\" x=\"380\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 0]</text>\r\n",
       "<text text-anchor=\"start\" x=\"373\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\r\n",
       "</g>\r\n",
       "<!-- 9&#45;&gt;10 -->\r\n",
       "<g id=\"edge10\" class=\"edge\"><title>9&#45;&gt;10</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M472.435,-103.726C466.837,-94.9703 460.913,-85.7032 455.289,-76.9051\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"458.123,-74.8399 449.787,-68.2996 452.225,-78.6103 458.123,-74.8399\"/>\r\n",
       "</g>\r\n",
       "<!-- 11 -->\r\n",
       "<g id=\"node12\" class=\"node\"><title>11</title>\r\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M614.5,-68C614.5,-68 522.5,-68 522.5,-68 516.5,-68 510.5,-62 510.5,-56 510.5,-56 510.5,-12 510.5,-12 510.5,-6 516.5,-0 522.5,-0 522.5,-0 614.5,-0 614.5,-0 620.5,-0 626.5,-6 626.5,-12 626.5,-12 626.5,-56 626.5,-56 626.5,-62 620.5,-68 614.5,-68\"/>\r\n",
       "<text text-anchor=\"start\" x=\"526.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"529\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\r\n",
       "<text text-anchor=\"start\" x=\"520\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 1]</text>\r\n",
       "<text text-anchor=\"start\" x=\"518.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\r\n",
       "</g>\r\n",
       "<!-- 9&#45;&gt;11 -->\r\n",
       "<g id=\"edge11\" class=\"edge\"><title>9&#45;&gt;11</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M524.565,-103.726C530.163,-94.9703 536.087,-85.7032 541.711,-76.9051\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"544.775,-78.6103 547.213,-68.2996 538.877,-74.8399 544.775,-78.6103\"/>\r\n",
       "</g>\r\n",
       "<!-- 13 -->\r\n",
       "<g id=\"node14\" class=\"node\"><title>13</title>\r\n",
       "<path fill=\"#8139e5\" fill-opacity=\"0.498039\" stroke=\"black\" d=\"M737,-306C737,-306 592,-306 592,-306 586,-306 580,-300 580,-294 580,-294 580,-235 580,-235 580,-229 586,-223 592,-223 592,-223 737,-223 737,-223 743,-223 749,-229 749,-235 749,-235 749,-294 749,-294 749,-300 743,-306 737,-306\"/>\r\n",
       "<text text-anchor=\"start\" x=\"588\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">sepal length (cm) ≤ 5.95</text>\r\n",
       "<text text-anchor=\"start\" x=\"614.5\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.918</text>\r\n",
       "<text text-anchor=\"start\" x=\"625\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\r\n",
       "<text text-anchor=\"start\" x=\"616\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 2]</text>\r\n",
       "<text text-anchor=\"start\" x=\"614.5\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\r\n",
       "</g>\r\n",
       "<!-- 12&#45;&gt;13 -->\r\n",
       "<g id=\"edge13\" class=\"edge\"><title>12&#45;&gt;13</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M664.5,-341.907C664.5,-333.649 664.5,-324.864 664.5,-316.302\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"668,-316.021 664.5,-306.021 661,-316.021 668,-316.021\"/>\r\n",
       "</g>\r\n",
       "<!-- 16 -->\r\n",
       "<g id=\"node17\" class=\"node\"><title>16</title>\r\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M876,-298.5C876,-298.5 779,-298.5 779,-298.5 773,-298.5 767,-292.5 767,-286.5 767,-286.5 767,-242.5 767,-242.5 767,-236.5 773,-230.5 779,-230.5 779,-230.5 876,-230.5 876,-230.5 882,-230.5 888,-236.5 888,-242.5 888,-242.5 888,-286.5 888,-286.5 888,-292.5 882,-298.5 876,-298.5\"/>\r\n",
       "<text text-anchor=\"start\" x=\"785.5\" y=\"-283.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"784\" y=\"-268.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 43</text>\r\n",
       "<text text-anchor=\"start\" x=\"775\" y=\"-253.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 43]</text>\r\n",
       "<text text-anchor=\"start\" x=\"777.5\" y=\"-238.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\r\n",
       "</g>\r\n",
       "<!-- 12&#45;&gt;16 -->\r\n",
       "<g id=\"edge16\" class=\"edge\"><title>12&#45;&gt;16</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M721.052,-341.907C737.808,-329.88 756.122,-316.735 772.761,-304.791\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"775.21,-307.342 781.293,-298.667 771.128,-301.655 775.21,-307.342\"/>\r\n",
       "</g>\r\n",
       "<!-- 14 -->\r\n",
       "<g id=\"node15\" class=\"node\"><title>14</title>\r\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M716,-179.5C716,-179.5 613,-179.5 613,-179.5 607,-179.5 601,-173.5 601,-167.5 601,-167.5 601,-123.5 601,-123.5 601,-117.5 607,-111.5 613,-111.5 613,-111.5 716,-111.5 716,-111.5 722,-111.5 728,-117.5 728,-123.5 728,-123.5 728,-167.5 728,-167.5 728,-173.5 722,-179.5 716,-179.5\"/>\r\n",
       "<text text-anchor=\"start\" x=\"622.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"625\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\r\n",
       "<text text-anchor=\"start\" x=\"616\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 0]</text>\r\n",
       "<text text-anchor=\"start\" x=\"609\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\r\n",
       "</g>\r\n",
       "<!-- 13&#45;&gt;14 -->\r\n",
       "<g id=\"edge14\" class=\"edge\"><title>13&#45;&gt;14</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M664.5,-222.907C664.5,-212.204 664.5,-200.615 664.5,-189.776\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"668,-189.667 664.5,-179.667 661,-189.667 668,-189.667\"/>\r\n",
       "</g>\r\n",
       "<!-- 15 -->\r\n",
       "<g id=\"node16\" class=\"node\"><title>15</title>\r\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M850.5,-179.5C850.5,-179.5 758.5,-179.5 758.5,-179.5 752.5,-179.5 746.5,-173.5 746.5,-167.5 746.5,-167.5 746.5,-123.5 746.5,-123.5 746.5,-117.5 752.5,-111.5 758.5,-111.5 758.5,-111.5 850.5,-111.5 850.5,-111.5 856.5,-111.5 862.5,-117.5 862.5,-123.5 862.5,-123.5 862.5,-167.5 862.5,-167.5 862.5,-173.5 856.5,-179.5 850.5,-179.5\"/>\r\n",
       "<text text-anchor=\"start\" x=\"762.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"start\" x=\"765\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\r\n",
       "<text text-anchor=\"start\" x=\"756\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 2]</text>\r\n",
       "<text text-anchor=\"start\" x=\"754.5\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\r\n",
       "</g>\r\n",
       "<!-- 13&#45;&gt;15 -->\r\n",
       "<g id=\"edge15\" class=\"edge\"><title>13&#45;&gt;15</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M713.072,-222.907C727.332,-210.99 742.905,-197.976 757.092,-186.12\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"759.384,-188.765 764.813,-179.667 754.895,-183.394 759.384,-188.765\"/>\r\n",
       "</g>\r\n",
       "</g>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<graphviz.files.Source at 0x1f1bf0230b8>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dot_data = tree.export_graphviz(clf, out_file=None,\n",
    "                               feature_names=iris.feature_names,\n",
    "                               class_names=iris.target_names,\n",
    "                               filled=True, \n",
    "                               rounded=True,\n",
    "                               special_characters=True)\n",
    "graph = graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
